Skip to content

feat: auto-link GitHub profile from OAuth#1356

Open
evanjacobson wants to merge 18 commits intomainfrom
feature/user-profile-autoconnect-github
Open

feat: auto-link GitHub profile from OAuth#1356
evanjacobson wants to merge 18 commits intomainfrom
feature/user-profile-autoconnect-github

Conversation

@evanjacobson
Copy link
Contributor

@evanjacobson evanjacobson commented Mar 21, 2026

Summary

  • When a user links GitHub via OAuth, their profile card automatically shows https://github.com/<username> derived from the OAuth display_name, overriding any manually set github_url
  • The edit profile modal replaces the GitHub text input with a link to /connected-accounts when GitHub is OAuth-linked, fully excluding the field from state, validation, and mutation
  • Manual github_url is preserved in the DB and resurfaces if the user unlinks GitHub

Blocked by

UI

image image

Test plan

  • Link GitHub via OAuth → profile card shows https://github.com/<login>
  • Edit profile modal shows "Linked via GitHub" message instead of text input
  • Clicking "Change in Connected Accounts" navigates to /connected-accounts
  • Saving LinkedIn-only changes works when GitHub is OAuth-linked
  • Unlink GitHub → manual github_url resurfaces in both card and edit modal
  • Users without GitHub OAuth linked see existing manual input behavior
  • GitHub login with special characters (if any) is validated before storage

When a user links GitHub via OAuth, their profile card now shows
the GitHub profile URL derived from the OAuth display_name, overriding
any manually set github_url. The edit modal replaces the GitHub text
input with a link to /connected-accounts when GitHub is OAuth-linked.
When GitHub is linked via OAuth, the edit modal now fully excludes the
GitHub field from state, validation, and mutation — preventing stale
manual values from interfering. Also validates GitHub login format
and improves comment accuracy on display_name assignments.
Replace inline auth provider query in profile page with a dedicated
getOAuthDisplayNames function that returns a Map<AuthProviderId, string>
for O(1) lookup. Query filters for non-null display_name in SQL.
@evanjacobson evanjacobson changed the base branch from main to feature/user-profile-connect-social-accounts March 21, 2026 01:51
@evanjacobson evanjacobson marked this pull request as ready for review March 21, 2026 02:54
@evanjacobson evanjacobson marked this pull request as draft March 21, 2026 02:54
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 21, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (6 files)
  • packages/trpc/dist/index.d.ts
  • src/app/(app)/profile/page.tsx
  • src/components/profile/EditProfileDialog.tsx
  • src/components/profile/UserProfileCard.tsx
  • src/lib/user.server.ts
  • src/lib/user.ts

Reviewed by gpt-5.4-20260305 · 1,489,288 tokens

evanjacobson added a commit that referenced this pull request Mar 23, 2026
…cation (#1354)

## Summary

- Add Discord as an OAuth auth provider on the user profile page, using
a separate Discord OAuth app (distinct from the existing bot)
- Add Discord guild membership verification — checks if the user is a
member of the Kilo Discord server via the bot API
- Auto-verify guild membership when a user first links their Discord
account; re-verify button available for non-members
- New DB migration adds `discord_server_member` and
`discord_server_member_at` columns to `kilocode_users`

## Verification

- [x] `pnpm typecheck` — passes
- [x] `pnpm test` — passes
- [x] Link Discord account on profile page
- [x] Guild membership auto-verifies after linking
- [x] Re-verify button works for non-members
- [x] Soft delete nullifies new Discord columns

## Visual Changes

New "Discord Server Membership" card on the user profile page showing:
- Prompt to link Discord if not connected
- Green checkmark with verification date if user is a Kilo Discord
member
- "Not a member" status with invite link and re-verify button otherwise

## Loom (Kilo Team only)
https://www.loom.com/share/3512eb86ef38454d86c95fa7cbfc51f1

## Other PRs for this feature
#1356 

## Reviewer Notes

- Discord OAuth app env vars (`DISCORD_OAUTH_CLIENT_ID`,
`DISCORD_OAUTH_CLIENT_SECRET`) are separate from the existing bot token
(`DISCORD_OAUTH_BOT_TOKEN`) — the bot token is used server-side for
guild membership checks
- `discord_provider_account_id` was intentionally excluded from the
`getDiscordGuildStatus` response to minimize API surface
- Guild check errors are caught and sanitized to avoid leaking internal
details (rate limits, missing env vars) to the client
Base automatically changed from feature/user-profile-connect-social-accounts to main March 23, 2026 18:55
evanjacobson added a commit that referenced this pull request Mar 24, 2026
## Summary

#1354 with db migrations not breaking.
- there is zero diff between the other files and the previous PR

- Add Discord as an OAuth auth provider on the user profile page, using
a separate Discord OAuth app (distinct from the existing bot)
- Add Discord guild membership verification — checks if the user is a
member of the Kilo Discord server via the bot API
- Auto-verify guild membership when a user first links their Discord
account; re-verify button available for non-members
- New DB migration adds `discord_server_member` and
`discord_server_member_at` columns to `kilocode_users`

## Verification

- [x] `pnpm typecheck` — passes
- [x] `pnpm test` — passes
- [x] Link Discord account on profile page
- [x] Guild membership auto-verifies after linking
- [x] Re-verify button works for non-members
- [x] Soft delete nullifies new Discord columns

## Visual Changes

New "Discord Server Membership" card on the user profile page showing:
- Prompt to link Discord if not connected
- Green checkmark with verification date if user is a Kilo Discord
member
- "Not a member" status with invite link and re-verify button otherwise

## Loom (Kilo Team only)
https://www.loom.com/share/3512eb86ef38454d86c95fa7cbfc51f1

## Other PRs for this feature
#1356 

## Reviewer Notes

- Discord OAuth app env vars (`DISCORD_OAUTH_CLIENT_ID`,
`DISCORD_OAUTH_CLIENT_SECRET`) are separate from the existing bot token
(`DISCORD_OAUTH_BOT_TOKEN`) — the bot token is used server-side for
guild membership checks
- `discord_provider_account_id` was intentionally excluded from the
`getDiscordGuildStatus` response to minimize API surface
- Guild check errors are caught and sanitized to avoid leaking internal
details (rate limits, missing env vars) to the client
@evanjacobson evanjacobson marked this pull request as ready for review March 24, 2026 20:13
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trpc changes from #1451 did not get regenerated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant